class FileContext:
    def __init__(self, file_name):
        self.file_name = file_name

    def __enter__(self):
        self.file = open(self.file_name)

    def __exit__(self, exc_type, exc_val, exc_tb):
        self.file.close()


if __name__ == '__main__':
    my_file_context = FileContext('week10_homework.py')
    with my_file_context:
        print(my_file_context.file.read())